home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 015a / fdate41a.zip / FDATE.DOC < prev    next >
Text File  |  1992-01-03  |  35KB  |  887 lines

  1. FDATE      Version 4.1a                          Jan 03, 1992
  2. ===================================================================
  3. FDATE: a utility for date manipulation in batch files.
  4. ===================================================================
  5. Stephen Ferg             5113 N. 8th Road, Arlington, VA 22205-1201
  6. Voice (703) 525-2241     CompuServe 73377,1157
  7.  
  8. =======================================================================
  9. Format:
  10. FDATE /Ffunc /Adate /Bdate /Iformat /Oformat /Nnum /Ddayofweek /Pstring
  11. =======================================================================
  12.  
  13.  
  14. FDATE PARAMETERS
  15. ================
  16.  
  17. The parameters that are required depend on the function requested.
  18. Parameters that are specified, but not needed, are ignored.
  19. Executing FDATE without any parameters displays a brief help screen.
  20.  
  21. Parameters can be in any order and upper or lower case.
  22.      Note that although format specifications are not case sensitive,
  23.      they ARE "text sensitive".  If any characters are missing,
  24.      added, or mistyped, the format specification will be rejected.
  25.      (A common mistake is to enter "/format" instead of "/Fformat".
  26.       This mistake can be avoided by using the /Ff function alias.)
  27.  
  28.  /F  requests a particular FDATE function
  29.      If this parameter is not specified, or is specified incorrectly,
  30.      FDATE displays a help screen.  If you unexpectedly get the help
  31.      screen displayed, you probably have omitted the /F parameter.
  32.  
  33.  /N  number of days (always a number)
  34.  /A  date A         (for math functions, a number)
  35.  /B  date B         (for math functions, a number)
  36.  
  37.  /I  specifies format of input date(s)
  38.  /O  specifies format of output date
  39.  
  40.  /L  specifies language of output.   If omitted, English is assumed.
  41.      /Leng  English-language output  [the default]
  42.      /Lfr   French-language output
  43.  
  44.  /P  specifies a prefix string for the output
  45.      This optional parameter may always be specified or omitted.
  46.      Prefix string must be enclosed in single or double quotes
  47.      EXAMPLE:  FDATE /Fformat /Atoday /O"mn zd, ccyy" /P"Today is "
  48.  
  49.      Note that multiple spaces will be removed from a /P paramaeter
  50.      string, so formatting of /P strings cannot be controlled using
  51.      spaces.  To format strings, use periods or ASCII 255 (hex'ff')
  52.      as filler.
  53.  
  54. ERROR HANDLING
  55. ==============
  56.  
  57.    If FDATE detects an error:
  58.      (1) it will return an errorlevel of 1
  59.      (2) its output will be 3 lines:
  60.        * the word ERROR
  61.        * a DOS batch-file ECHO statement that displays an error message
  62.        * a DOS batch-file PAUSE statement
  63.  
  64.    If Fdate output is piped to an environment manipulation utility such
  65.    as STRINGS or GET, the environment variable will be set to ERROR.
  66.  
  67.    If Fdate output is redirected to a batch file, which is then
  68.    executed to set an environment variable, the batch file will:
  69.      * set the environment variable to ERROR,
  70.      * ECHO the error message, and
  71.      * pause.
  72.  
  73.    Appropriate batch-file code for error checking for FDATE might be:
  74.      Fdate [parms]....
  75.      if errorlevel 1 echo FDATE ENCOUNTERED AN ERROR
  76.      if errorlevel 1 goto endit
  77.  
  78.  
  79.  
  80.  
  81.  
  82. SYMBOL CONVENTIONS
  83. ==================
  84.  
  85. The following symbols are used in specifying date formats:
  86.  
  87. SYMBOL  EXAMPLE   MEANING
  88. ------  -------   -------------------------------------
  89. cc        19      century
  90. yy        85      year
  91. mm        02      month
  92. zm         2      month without leading zero
  93. dd        09      day
  94. zd         9      day   without leading zero
  95. mn       January  month name
  96. mn3      Jan      month name, first 3 characters only
  97. dow      Tuesday  day of week
  98. dow3     Tue      day of week, first 3 characters only
  99. dow#      3       day of week as a number (Sunday=1, Monday = 2, etc.)
  100. today             is a "pseudodate" representing the current date
  101. t                 is an alias for the "today" pseudodate
  102. hh:mm    09:05    hours and minutes
  103. ss        09      seconds
  104.  
  105.  
  106.  
  107. PSEUDODATES
  108. ===========
  109.  
  110. t (or today)
  111.           can be used with either /A or /B, e.g. /Atoday or /At.
  112.  
  113. EXAMPLE
  114.           rem Get the date that is 90 days from today
  115.           FDATE /Fadd /N90 /Atoday /Omm-dd-ccyy
  116.           FDATE /Fadd /N90 /At     /Omm-dd-ccyy
  117.  
  118.           rem determine if this year is a leapyear
  119.           FDATE /Ff /At /OLY
  120.  
  121. tt        when used in place of a 2-digit DD string, will cause
  122.           Fdate to use today's day-of-the-month.
  123.           Example:    FDATE /Ff /Imm-dd-ccyy /A01-tt-1992 /Od1
  124.  
  125. tt        when used in place of a 2-digit MM string, will cause
  126.           Fdate to use today's month.
  127.           Example:    FDATE /Ff /Imm-dd-ccyy /Att-01-1992 /Od1
  128.  
  129. tt        when used in place of a 2-digit YY string, will cause
  130.           Fdate to use today's year (CCYY).
  131.           Example:    FDATE /Ff /Imm-dd-yy /A01-01-tt /Od1
  132.  
  133.           Note that TT can NOT be used for only the YY part of a CCYY
  134.           input year.  The following, for example, is NOT valid:
  135.           Example:    FDATE /Ff /Imm-dd-ccyy /A01-01-19tt /Od1
  136.  
  137. tttt      when used in place of a 4-digit CCYY string, will cause
  138.           Fdate to use today's year (CCYY).
  139.           Example:    FDATE /Ff /Imm-dd-ccyy /A01-01-tttt /Od1
  140.  
  141.  
  142. EXAMPLES:
  143.  
  144. Show the first Monday in the second quarter of this year
  145. FDATE /Fw /Iccyymmdd /Atttt0301 /D2 /N1 /Od1 /P"First Monday in QTR#2: "
  146.  
  147. Show the last Friday on/before the 15th of this month.
  148. FDATE /Fw /Iccyymmdd /Atttttt15 /D6 /N-1 /Od1 /P"Friday before the 15th: "
  149.  
  150.  
  151. INPUT FORMATS
  152. =============
  153.  
  154. FORMAT      EXAMPLES      DISCUSSION
  155. ------      ---------     -----------------------------
  156. ccyymmdd    19922002
  157.  
  158. mm-dd-ccyy  02-20-1992    In an input format specification, the dash
  159.             02/20/1992    symbols represent ANY non-numeric symbol.
  160.              2/20/1992    Leading zeros need not be present.
  161.  
  162. mm-dd-yy    02-20-92      In this input format,
  163.             02/20/92      cc=19 is assumed if YY is greater than 20
  164.             02/20/92      otherwise, cc=20 is assumed
  165.  
  166.  
  167. NOTE
  168. If ALL input dates are specified using the "today" pseudodate, (i.e.
  169. /At, /Bt) then it is not necessary to supply an input format using /I.
  170.  
  171.  
  172.  
  173.  
  174. OUTPUT FORMATS
  175. ==============
  176.  
  177. FORMAT        EXAMPLES      DISCUSSION
  178. ------        ---------     -----------------------------
  179. ccyy          1992
  180. ccyymm        199202        useful for triggering monthly processing
  181. ccyymmdd      19920220      useful for putting current date in filename
  182.   yymmdd        920220      useful for putting current date in filename
  183.     mmdd          0220
  184. dd-mn3-yy     02-Feb-92     CompuServe-style date
  185.  
  186. In the following formats, months precede days (American style)
  187. ------------------------------------------------------------------
  188. mm/dd/ccyy    02/20/1992
  189. mm-dd-ccyy    02-20-1992
  190. zm/zd/ccyy     2/20/1992    no leading zeros in day or month
  191. zm-zd-ccyy     2-20-1992    no leading zeros in day or month
  192. mm/dd/yy      02/20/92
  193. mm-dd-yy      02-20-92
  194. zm/zd/yy       2/20/92      no leading zeros in day or month
  195. zm-zd-yy       2-20-92      no leading zeros in day or month
  196.  
  197. In the following formats, days precede months  (European style)
  198. ------------------------------------------------------------------
  199. dd/mm/ccyy    02/20/1992
  200. dd-mm-ccyy    02-20-1992
  201. zd/zm/ccyy     2/20/1992    no leading zeros in day or month
  202. zd-zm-ccyy     2-20-1992    no leading zeros in day or month
  203. dd/mm/yy      02/20/92
  204. dd-mm-yy      02-20-92
  205. zd/zm/yy       2/20/92      no leading zeros in day or month
  206. zd-zm-yy       2-20-92      no leading zeros in day or month
  207.  
  208. ------------------------------------------------------------------
  209.  
  210. Day-of-the-week output formats
  211. ------------------------------------------------------------------
  212.  
  213. dow#           5            Sunday=1, Monday=2 .... Saturday=7.
  214.  
  215. dow            Thursday     name of day of week
  216.                Jeudi        if /Lfr specified
  217.  
  218. dow3           Thu          first 3 characters of name of day of week
  219.                Jeu          if /Lfr specified
  220.  
  221. ------------------------------------------------------------------
  222.  
  223.  
  224. LY              0           1 if year is a leapyear, otherwise 0.
  225.                                ------------------------------------
  226.                                365 + this number gives total
  227.                                      number of days in the year.
  228.                                 28 + this number gives total
  229.                                      number of days in February.
  230.                                ------------------------------------
  231.  
  232. d1           Saturday, February 5, 1992
  233.              le Samedi 5 Fevrier 1992      [/Lfr specified]
  234.  
  235. t1            9:05 pm
  236.  
  237. HH:MM        09:05   ("Military time") (9:05 am)
  238.              21:05                     (9:05 pm)
  239.  
  240. HH:MM:SS     21:05:30
  241.  
  242. full          9:05 pm on Saturday, February 5, 1992
  243.               9:05 pm le Samedi 5 Fevrier 1992      [/Lfr specified]
  244. -----------------------------------------------------------------------
  245. NOTE that the following formats contain embedded spaces.  Consequently
  246. they must be enclosed in double quotes. EXAMPLE: /O"mn zd, ccyy".
  247. -----------------------------------------------------------------------
  248. "zd mn ccyy"      5 February 1992
  249. "zd mn, ccyy"     5 February, 1992
  250. "mn3 dd ccyy"     Feb 05 1992
  251. "mn3 dd, ccyy"    Feb 05, 1992
  252. "mn zd, ccyy"     February 5, 1992
  253.  
  254.  
  255.  
  256. "JULIAN" OUTPUT FORMATS
  257. =======================
  258.  
  259. FORMAT        EXAMPLES      DISCUSSION
  260. ------        ---------     -----------------------------
  261.  
  262. julian            311       BUSINESS "Julian date" expressed as number
  263.                             of days since January 1 of the same year.
  264.  
  265. day#           727198       TRUE "Julian date" expressed as number
  266.                             of days since January 1, 0001.
  267.  
  268. minute#         33088       "Julian minutes": time expressed as number
  269.                             of minutes  since midnight, January 1, 1990.
  270.  
  271. second#        633088       "Julian seconds": time expressed as number
  272.                             of seconds  since midnight, January 1, 1990.
  273.  
  274. ----------------------------------------------------------------------
  275.    Running FDATE with /O parameter for a "Julian time" produces a
  276.    number based on the current time of day and the date in the /A parm.
  277.  
  278.    If, on January 10, 1992 at 2 pm, you run FDATE this way:
  279.        FDATE /Ff /Atoday /Ominute#
  280.    it will produce the Julian minute for January 10, 1992 at 2 pm.
  281.  
  282.    If, on January 10, 1992 at 2 pm, you run FDATE this way:
  283.        FDATE /Ff /A01-15-1992 /Imm-dd-ccyy  /Ominute#
  284.    it will produce the Julian minute for January 15, 1992 at 2 pm.
  285. ----------------------------------------------------------------------
  286.  
  287. DATE FUNCTIONS
  288. ==============
  289.  
  290. FUNCTION  FDATE /Ffunc /Adate /Iformat /Oformat
  291. --------  -------------------------------------------
  292. format    this is a synonym for function "f"
  293.  
  294. f         returns /Adate in format specified by /Oformat
  295.           Since /Aformat and /Oformat can be different, the FORMAT
  296.           function is used to change a date from one format to another.
  297.           Because of the wide variety of output formats, the FORMAT
  298.           function can also be used to determine the day of week of the
  299.           date, whether the date is in a normal or leap year, etc.
  300.  
  301. EXAMPLES
  302.           FDATE /Ff /A19920101 /Iccyymmdd /O"mn zd, ccyy"
  303.           FDATE /Ff       /Atoday         /Od1
  304.           FDATE /Fformat  /Atoday         /Od1
  305.  
  306.  
  307.  
  308. FUNCTION  FDATE /Ffunc /Nnumdays /Adate /Iformat /Oformat
  309. --------  -------------------------------------------
  310. add       Adds      /Ndays to   /Adate, produces date in /Oformat format
  311. sub       Subtracts /Ndays from /Adate, produces date in /Oformat format
  312.  
  313. EXAMPLES
  314.           FDATE /Fadd /N90 /A01-01-1992 /Imm-dd-ccyy /Od1
  315.           FDATE /Fsub /N90 /A01-01-1992 /Imm-dd-ccyy /Od1
  316.           FDATE /Fadd /N90 /Atoday                   /Od1
  317.  
  318.  
  319.  
  320. FUNCTION  FDATE /Ffunc /Adate /Bdate /Iformat
  321. --------  -------------------------------------------
  322. comp      compares the dates specified on the /A and /B parms.
  323.           returns         when
  324.             LT            /A  is less than    (earlier than) /B
  325.             EQ            /A  is equal to     (same as)      /B
  326.             GT            /A  is greater than (later than)   /B
  327.  
  328. dif       Returns number of days between /Adate and /Bdate
  329.           Order of the two dates is not significant.
  330.           Note that for DIF, both dates must be in the SAME
  331.           format, the input format specified in /Iformat.
  332.           If the two dates are not in the same format, reformat one
  333.           of the dates using the /Ff function and
  334.           a utility like STRINGS or GET.
  335.  
  336. EXAMPLES
  337.           FDATE /Fdif /A01-01-1992 /B11-11-1992  /Imm-dd-ccyy
  338.           FDATE /Fdif /A11-11-1992 /B01-01-1992  /Imm-dd-ccyy
  339.           FDATE /Fdif /Atoday      /B01-01-1992  /Imm-dd-ccyy
  340.  
  341.  
  342. FUNCTION  FDATE /Ffunc /Adate /Iformat /Oformat /Ddow#  /Ndow-count
  343. --------  -------------------------------------------
  344. w         W (weekday) function.
  345.           This function accepts a date specification in parm /A and
  346.           returns the date of the /Nth /Day-of-the-week
  347.           before or after /Adate.  For example:
  348.  
  349.           If    /A specifies November 14, 1992
  350.                 /D specifies the number for Thursday (i.e., 5)
  351.                 /N specifies a week count of 3
  352.           then /Fw returns the date of the third Thursday after
  353.           November 14, 1992. (See full example, below)
  354.  
  355.           Note that /N may be negative.  If, in the above example, /N
  356.           is specified as -3, then Fdate returns the date of the third
  357.           Thursday BEFORE November 14, 1992.
  358.  
  359.           If the date specified on the /A parms falls on the same day
  360.           of the week as was specified on the /D parm, then that will
  361.           be considered to be the first date meeting that day-of-week
  362.           criterion.  That is, If November 14, 1992 fell on a
  363.           Thursday, and if /N was 1 or -1, then the output date would
  364.           be the same as the input date, i.e.  November 14, 1992.
  365.  
  366.           The acceptable values for /N (number of weeks) is in
  367.           the range of 99..-99.  A value of zero (i.e. /N0) is invalid.
  368.  
  369. EXAMPLES
  370.      find date of Thanksgiving (4th Thursday in November) in 1992
  371.          FDATE /Fw /A11-01-1992 /Imm-dd-ccyy /D5 /N4 /Od1
  372.      returns: Thursday November 26, 1992
  373.  
  374.      find the beginning of the work-week (Monday, 2nd day of week)
  375.      AFTER Thanksgiving, 1992
  376.          FDATE /Fw /A11-26-1992 /Imm-dd-ccyy /D2 /N1 /Od1
  377.  
  378.      find the beginning of the work-week (Monday, 2nd day of week)
  379.      BEFORE Thanksgiving, 1992
  380.          FDATE /Fw /A11-26-1992 /Imm-dd-ccyy /D2 /N-1 /Od1
  381.  
  382.  
  383. MATH FUNCTIONS
  384. ==============
  385.  
  386. FUNCTION  FDATE /Ffunc /Anum  /Bnum
  387. --------  -------------------------------------------
  388.  
  389. #add      returns the sum of the integers specified
  390.           on the /A and /B parms.  Can be used to calculate the
  391.           "Julian" minute(second, date) in the future from a given
  392.           "Julian" minute(second, date).
  393.  
  394. #sub      (not supported)
  395.           no numeric subtraction operation (as such) is supported.
  396.           Often, you will find that #dif will do what you want.
  397.           #dif is the same as subtraction in which the smaller
  398.           number is subtracted from the larger number; it will never
  399.           return a negative number.  If you really MUST have
  400.           subtraction, which might return a negative result, you can
  401.           add two numbers, one of which is a negative number.
  402.           For example, to subtract 3 from 2:
  403.               FDATE /F#add /A2 /B-3          [ returns: -1 ]
  404.  
  405. #dif      returns the difference between the integers specified
  406.           on the /A and /B parms.  Can be used to calculate the
  407.           number of minutes(seconds, days) between two
  408.           "Julian"  minutes(seconds, dates).
  409.  
  410. #comp     compares the integers specified on the /A and /B parms.
  411.           returns         when
  412.             LT            /A  is less    than /B
  413.             EQ            /A  is equal   to   /B
  414.             GT            /A  is greater than /B
  415.  
  416.  
  417. PUTTING FDATE OUTPUT INTO AN ENVIRONMENT VARIABLE
  418. =================================================
  419.  
  420. FDATE's output is written to standard output, that is, it is displayed
  421. on the screen.  Output can be redirected to a file, or it can piped to
  422. a utility (such as STRINGS or GET) that will put it into an
  423. environment variable.
  424.  
  425. Manipulating the environment is an incredibly tricky business.  There
  426. are questions of the local versus master environment, the version of
  427. DOS you are running, and the environment under which you are running
  428. (DOS, Windows, Carousel).  In order to keep FDATE focussed on
  429. date-related issues, I have not attempted to make it put its output
  430. directly into an environment variable.
  431.  
  432. One way to put FDATE's output into an environment variable is to use
  433. the /P (prefix string) feature to create a DOS "SET" statement,
  434. redirect the output to a batch file, and CALL the batch file.
  435. Since CALL first appeared in DOS 3.3, you will need DOS 3.3 or
  436. greater to use this technique.
  437.  
  438.   FDATE /Ff /Atoday /O"mn zd, ccyy" /P"@SET FDATE=" >JUNKTEMP.BAT
  439.   call JUNKTEMP.BAT
  440.   del  JUNKTEMP.BAT
  441.  
  442. There are also shareware and public domain utilities that are written
  443. specifically to manipulate environment variables, and do that job very
  444. well.  FDATE's output can be put into an environment variable by piping
  445. it to one of these utilities.  When piping FDATE output to a utility,
  446. you can prevent the output from being ECHOed to the screen by
  447. redirecting the output to NUL.
  448.  
  449.    EXAMPLE: use STRINGS to put date into DATE1 environment variable
  450.    FDATE /Ff /At /Od1 | STRINGS date1= ASK >NUL
  451.  
  452.    -----------------------------------------------------------------
  453.    I recommend Bob Stephan's GET and PC Magazine's STRINGS.
  454.    As of December 30, 1991, the current version of GET is GET25.ZIP.
  455.    On CompuServe, use IBMFF to look for GET*.ZIP in CIS:IBMSYS
  456.    GET is also available from the Public Software Library in Houston.
  457.    On CompuServe, look for STRING.ZIP in Utilities Lib of ZNT:UTILFORUM
  458.    -----------------------------------------------------------------
  459.  
  460. =======================================================================
  461. EXAMPLE #1
  462. Redirect FDATE output to a file, or to a callable batch file,
  463. or pipe it to STRINGS or GET to store it in an environment variable
  464. =======================================================================
  465. rem display Fdate output on screen
  466. FDATE /Ff /At /Od1 /P"Today is "
  467.  
  468. rem Redirect FDATE output to a file
  469. FDATE /Ff /At /Od1 /P"Today is " >FDATE.OUT
  470.  
  471. rem Redirect FDATE output to a callable batch file
  472. FDATE /Ff /Atoday /O"mn zd, ccyy" /P"@SET DATE1=" >JUNKTEMP.BAT
  473. call JUNKTEMP.BAT
  474. del  JUNKTEMP.BAT
  475.  
  476. rem Pipe FDATE output to STRINGS to store it in DATE1 environment var
  477. FDATE /Ff /Atoday /O"mn zd, ccyy" |STRINGS date1= ASK >NUL
  478.  
  479. rem Pipe FDATE output to GET to store it in DATE1 environment var
  480. FDATE /Ff /Atoday /O"mn zd, ccyy" |GET ZE /Vdate1 >NUL
  481.  
  482.  
  483.  
  484. =======================================================================
  485. EXAMPLE #2
  486. Find the difference (in days) between two dates in different formats
  487. Use GET to put FDATE output into environment variables.
  488. =======================================================================
  489. set date1=05-10-1992
  490.  
  491. rem reformat date literal into same format as date1
  492. FDATE /Ff /Imm-dd-yy   /A05-08-92 /Omm-dd-ccyy | GET ZE /Vdate2>NUL
  493.  
  494. rem get difference between date1 and date2
  495. FDATE /Fdif /Imm-dd-ccyy /A%date1%  /B%date2%| GET ZE /vdiff>NUL
  496.  
  497. echo The difference is %diff% days.
  498.  
  499.  
  500.  
  501.  
  502. =======================================================================
  503. EXAMPLE #3
  504. Schedule a program to run at a specified time in the future.  Note that
  505. this involves a lot of disk activity because DOS re-reads the batch
  506. file from disk every time it does a GOTO LOOPTOP.  If you do this, it
  507. is a good idea to run the batch file from a RAM DISK.
  508. =======================================================================
  509. REM GET CURRENT JULIAN MINUTE AND PUT IN ENVIRONMENT VARIABLE RUNTIME
  510. FDATE /Ff /At /Ominute#  |STRINGS RunTime= ASK >NUL
  511.  
  512. REM ADD 120 MINUTES (2 HOURS) TO ENVIRONMENT VARIABLE RUNTIME
  513. FDATE /F#add /A%RunTime% /B120 |STRINGS RunTime= ASK >NUL
  514.  
  515. REM LOOP UNTIL NOWTIME HAS REACHED RUNTIME
  516. :LoopTop
  517.   FDATE /Ff /At  /Ominute#   |STRINGS NowTime=  ASK >NUL
  518.   FDATE /F#comp  /A%NowTime% /B%RunTime% |STRINGS TimeComp= ASK >NUL
  519.   if (%TimeComp%)==(LT) goto loopTOP
  520. :LoopEnd
  521.  
  522. echo STARTING EXECUTION OF APPLICATION: [program name]
  523.  
  524.  
  525.  
  526. =======================================================================
  527. EXAMPLE #4
  528. Rename file BACKUP.LOG to a name that contains today's date
  529. =======================================================================
  530. FDATE /Ff /Atoday /Oyymmdd /P"@SET DATE1=" >JUNKTEMP.BAT
  531. call JUNKTEMP.BAT
  532. del  JUNKTEMP.BAT
  533. ren  BACKUP.LOG  BK%DATE1%.LOG
  534. SET  DATE1=
  535.  
  536.  
  537.  
  538. =======================================================================
  539. EXAMPLE #4b
  540. Use FDATE to rename a log file to a name that will be unique within a
  541. minute time-frame.  This is a way to keep an historical record of a
  542. series of log files.  Since the file will retain its original date/time
  543. stamp, you will still be able easily to tell when it was created.
  544. In this example, we use GET to put the FDATE output into
  545. environment variable TEMPVAR.
  546. =======================================================================
  547. FDATE /FF /At /Ominute# | GET ZE /Vtempvar >nul
  548. REN online.log %tempvar%.log
  549. SET tempvar=
  550.  
  551.  
  552.  
  553. =======================================================================
  554. EXAMPLE #5
  555. Find the calendar date corresponding to Julian date 1992:200
  556. by adding 200 to the last day of the previous year.
  557. =======================================================================
  558. FDATE /Fadd /A12-31-1991 /Imm-dd-ccyy /N200 /Od1
  559.  
  560.  
  561.  
  562. =======================================================================
  563. EXAMPLE #6
  564. Check to see if parameter %1 is a valid year (CCYY)
  565. =======================================================================
  566. @echo off
  567. rem determine if value sent in through parameter %1 is a valid year
  568. Fdate /Ff /Imm-dd-ccyy /A01-01-%1 /Od1 >nul
  569. if errorlevel 1 echo Parm 1 was not a valid year: %1
  570. if errorlevel 1 goto endit
  571.  
  572. echo PUT YOUR BATCH PROCESSING HERE, USING YEAR VALUE OF: %1
  573.  
  574. :endit
  575.  
  576.  
  577.  
  578. =======================================================================
  579. EXAMPLE #7
  580. Find the 4th Thursday in November (Thanksgiving)
  581. =======================================================================
  582. Fdate /Fw /D5 /N4 /A11-01-%year% /Imm-dd-ccyy /Od1 /P"Thanksgiving: "
  583.  
  584.  
  585.  
  586. =======================================================================
  587. EXAMPLE #8
  588. Show the number of the anniversary for some special event.
  589. =======================================================================
  590. SEE HOLIDAYS.BAT
  591.  
  592.  
  593. =======================================================================
  594. EXAMPLE #9
  595. Run a program once a day, when you boot for the first time that day.
  596. =======================================================================
  597. @echo off
  598. cls
  599.  
  600. REM -------------------------------------------------------------------
  601. REM Run daily processing once a day.  Put this code in AUTOEXEC.BAT.
  602. REM This batch file requires DOS 3.3+, since it uses CALL.
  603. REM -------------------------------------------------------------------
  604. if not exist LastRun.BAT goto RunNow
  605. REM LastRun.Bat will set env var LASTRUN to date AUTOEXEC was last run.
  606. call LastRun.BAT
  607.  
  608. REM Compare today's date to date in LASTRUN
  609. Fdate /Fcomp /Imm-dd-ccyy /At /B%LastRun% /P"@set COMP=">junktemp.BAT
  610. call junktemp.BAT
  611. del  junktemp.BAT
  612.  
  613. IF (%COMP%)==(EQ) goto NoRun
  614. REM if user reset system clock, today's date may be less than LASTRUN
  615. IF (%COMP%)==(LT) goto NoRun
  616.  
  617. rem Daily processing hasn't been run today. Run it.
  618.  
  619. echo RUNNING ONCE A DAY PROCESSING: Job 1
  620. echo RUNNING ONCE A DAY PROCESSING: Job 2
  621. echo RUNNING ONCE A DAY PROCESSING: ............. etc.
  622.  
  623. rem ------------------------------------------------------------------
  624. rem Save today's date in a new version of LastRun.BAT
  625. rem Note that this will be executed only if daily processing runs to
  626. rem completion without hanging the machine or aborting the batch file.
  627. rem ------------------------------------------------------------------
  628. Fdate /Ff /Omm-dd-ccyy /At /P"@set LastRun=">LastRun.BAT
  629.  
  630. :NoRun
  631. set LastRun=
  632. set COMP=
  633.  
  634. FDATE'S ALGORITHMS
  635. ==================
  636.  
  637.  
  638. FDATE IS DESIGNED FOR BUSINESS, NOT HISTORICAL, APPLICATIONS
  639. ============================================================
  640. FDATE is intended for business applications, not historical ones.
  641. As far as FDATE is concerned, the calendar has followed the same
  642. pattern, unchanged, since January 1, 0001.
  643.     -------------------------------------------------------------------
  644.     FDATE does not take into account historical changes in the calendar
  645.     such as the glitch in English dates that occurred when Britain
  646.     moved from the Julian to Gregorian calendar in the 18th century,
  647.     or Russia made the same move in the early 20th century.
  648.     -------------------------------------------------------------------
  649.  
  650.  
  651. FDATE'S BASE DATE
  652. =================
  653.   Internally, date manipulations are based on translating a calendar
  654.   date into an "absolute" or "TRUE Julian" date:  a date expressed
  655.   as the number of days from some day in the distant past.
  656.   FDATE's base date is January 1, 0001 (i.e. day 1 of month 1 of year 1)
  657.   FDATE's absolute date for January 1, 0001 is      1.
  658.   FDATE's absolute date for January 1, 1992 is 727198.
  659.  
  660.  
  661. FDATE'S LEAP YEAR ALGORITHM
  662. ===========================
  663.     Every year evenly divisible by 4 IS a leap year
  664.       EXCEPT THAT
  665.         Every year evenly divisible by 100 IS NOT a leap year
  666.           EXCEPT THAT
  667.             Every year evenly divisible by 400 IS a leap year
  668.     .
  669.     Using this algorithm
  670.          1983  is not a leap year
  671.          1984  is     a leap year
  672.          1900  is not a leap year
  673.          2000  is     a leap year
  674.  
  675.     See "A Machine Algorithm for Processing Calendar Dates", by
  676.          Henry F. Fliegel (Georgetown University Observatory) and
  677.          Thomas C. Van Flandern (U.S. Naval Observatory)
  678.          COMMUNICATIONS OF THE ACM, Volume 11, Number 10, October 1968
  679.  
  680. There is supposedly a new adjustment to the leapyear algorithm,
  681. which specifies the additional exception:
  682.  
  683.               EXCEPT THAT
  684.                 Every year evenly divisible by 4000 IS a leap year
  685.  
  686. See "Bit By Bit" column, COMPUTER LANGUAGE, November 1989, p. 148.
  687. This adjustment is not part of FDATE's leapyear algorithm.
  688. Unless your application is working with dates 2,000 years in the
  689. future, the lack of this exception will be irrelevant for you.
  690.  
  691. USE AND DISTRIBUTION OF FDATE
  692. =============================
  693.  
  694. FDATE is freeware.  Although the author retains the copyright, FDATE
  695. can be copied, used, and distributed freely as long as both FDATE.EXE
  696. and its associated doc files (FDATE.DOC, FDATEX.BAT, HOLIDAYS.BAT)
  697. are not altered and are distributed together.
  698.  
  699. FDATE can be included in shareware packages as long as both FDATE and
  700. its doc files are included in the shareware package.
  701.  
  702. If you have received FDATE as part of some larger shareware package,
  703. please be aware that you may freely use, copy, and distribute FDATE
  704. without paying a fee for, or registering, the package.
  705.  
  706. The author explicitly disavows any claim whatsoever about the
  707. functionality of the software, and disclaims liability for anything and
  708. everything bad that might happen in connection with, before, during, or
  709. after using it.  I have tried to make FDATE work right, but everybody
  710. makes mistakes, so you use FDATE at your own risk.
  711.  
  712. I don't know if people will find FDATE useful, and I'd like to find
  713. out.  If you find FDATE useful and use it on a regular basis, I'd
  714. appreciate it if you would drop me a short note via US mail or
  715. CompuServe, telling me about how you are using FDATE.
  716.  
  717. If you need other input/output formats, or if you need a different
  718. leapyear algorithm, please contact the author.
  719.  
  720.  
  721.  
  722. UPDATES AND CURRENT VERSION OF FDATE
  723. ====================================
  724.  
  725. You will always be able to find the most recent version of FDATE on
  726. CompuServe.  The filename will be FDATE.ZIP, and it will be available in
  727. one of the libraries in the CIS:IBMSYS forum and one of the libraries in
  728. the ZNT:UTILFORUM forum.  You can find it by using cross-library
  729. searching, looking for the filename FDATE.ZIP or the keyword FDATE.
  730.  
  731. Feel free to post copies of FDATE.ZIP on any BBS that you wish, but
  732. please do not upload it to any CompuServe library.  As long as I am the
  733. only one putting copies of FDATE onto CompuServe, we can keep confusion
  734. over versions to a minimum.
  735.  
  736.  
  737. FDATE REVISION HISTORY
  738. ======================
  739.  
  740. Letters appended to version numbers indicate modifications to
  741. the doc files, without any modification to the FDATE.EXE software.
  742.  
  743. 1.1   Oct 01, 1991
  744.       First version of FDATE
  745.  
  746. 1.2   Oct 15, 1991
  747.       Replaced shareware date routines with Ferg routines
  748.       NOTE THAT THERE IS NOT MUCH ERROR-CHECKING IN THIS VERSION.
  749.  
  750. 1.2d  Oct 16, 1991
  751.       Minor changes to show redirection and piping of FDATE output
  752.       Revised discussion of how FDATE may be distributed.
  753.       Added note on business-related, non-historical purpose of FDATE
  754.       Added note on 4000-year leap-year exception
  755.  
  756. 1.2e  Oct 17, 1991
  757.       Added note on why FDATE doesn't directly set an Env variable
  758.  
  759. 2.0a  Nov 05, 1991
  760.       Modified Help display to show parameters and their meanings
  761.       Added output format YYMMDD
  762.       Added output format minute# and second#
  763.       Added function #dif
  764.       Added test of GET and STRINGS      to FDATEX.BAT
  765.       Added test of minute# and second#  to FDATEX.BAT
  766.  
  767. 2.1a  Nov 06, 1991
  768.       Added /P parameter and modified documentation accordingly
  769.       Added JULDATE output format
  770.       Minor changes and reformatting to documenation
  771.  
  772. 2.2a  Nov 08, 1991
  773.       Added example showing how to put current date in a filename
  774.       Added MMDD output formats
  775.  
  776. 2.3a  Nov 09, 1991
  777.       Added /L (language parameter) to allow French-language output
  778.       Added the following output formats
  779.          full
  780.          "mn3 zd, ccyy"
  781.          "zd mn, ccyy"
  782.          "zd mn ccyy"
  783.          European-style date formats
  784.                in which day occurs before month (e.g. dd/mm/ccyy)
  785.  
  786. 2.4a  Nov 10, 1991
  787.       Fixed display of time in /Ofull so that a minutes value of
  788.             less than 10 would display with a leading zero:
  789.             e.g. "10:08 am" instead of "10:8 am".
  790.  
  791. 2.5a  Nov 13, 1991
  792.       Added output format CCYYMM
  793.  
  794. 2.6a  Nov 25, 1991
  795.       Added function "F" (/Ff) as an synonym for /Fformat
  796.       Split FDATEX.BAT off from FDATE.DOC into its own file
  797.  
  798. 2.6b  Dec 02, 1991
  799.       Modified this doc file to reflect new /Ff feature
  800.  
  801. 2.7a  Dec 07, 1991
  802.       Added CompuServe-style output format: dd-mn3-yy.
  803.                                    Example: 07-Dec-91
  804.  
  805. 2.8a  Dec 08, 1991
  806.       Added output format d1.    Example:  Saturday December 7, 1991
  807.       Added output format t1.    Example:  9:05 am
  808.       Added "t" alias for "today" pseudodate.
  809.  
  810.       Corrected FDATE "help" display which had incorrectly shown
  811.          dd-mn3-yy as an input (rather than an output) format.
  812.       Modified documentation and FDATEX.BAT to reflect software changes.
  813.       Extensively re-wrote and re-arranged FDATEX.BAT to make it
  814.          more user-friendly.
  815.       In documentation:
  816.          corrected the formats for European dates, which had incorrectly
  817.          been shown as having the same format as American dates.
  818.  
  819. 2.8b  Dec 09, 1991
  820.       In documentation:
  821.          Added example showing how to use fdate to create a
  822.          time-stamped filename.
  823.  
  824. 2.9a  Dec 26, 1991
  825.       Added STRINGS and GET info to HELP screen.
  826.       In documentation:
  827.          Added example: how to find calendar date of Julian date
  828.  
  829. 3.0a  Dec 27, 1991
  830.       =============== MAJOR BUG FIX ==============================
  831.       Fixed bug in TRUEDATE date arithmetic routine that caused
  832.       incorrect dates to be returned for the last 2 or 3 days of
  833.       some months.
  834.       ============================================================
  835.       Added output formats ccyy, hh:mm, and hh:mm:ss.
  836.       Replaced output format JULDATE with JULIAN
  837.              JULDATE retained for compatibility, but not documented.
  838.       Modified this doc file and FDATEX.BAT accordingly.
  839.  
  840. 3.1a  Dec 28, 1991
  841.       Fixed bug: error messages were ignoring the /P parm
  842.       added HOLIDAYS.BAT to distribution package
  843.       Replaced output format LEAPYR with LY
  844.              LEAPYR retained for compatibility, but not documented.
  845.       Added new feature: when an error is detected:
  846.              output string is "ERROR", and
  847.              errorlevel is set to 1.
  848.       Changed assumed century on input formats that require only YY.
  849.              Now, if year is LT/EQ 20, a century of 20 is assumed.
  850.              FDATE will now be able to function nicely until year 2020.
  851.       Modified this doc file and FDATEX.BAT accordingly.
  852.  
  853. 3.2a  Dec 29, 1991
  854.       Added COMP (date compare) function
  855.       Added RUN-ONCE-A-DAY example, which uses new COMP function
  856.       Added error-trapping for dates before year 1 and after year 9999.
  857.       Fixed minor error in HELP screen (dif does NOT require /O).
  858.       Modified this doc file and FDATEX.BAT accordingly.
  859.  
  860. 3.2b  Dec 30, 1991
  861.       Fixed two bugs in this doc file. (Thanks to Luther Schliesser
  862.          for the bug report.)   My phone number was wrong, and the
  863.          values returned by the leapyear function (0,1) were reversed.
  864.       Fixed my phone number in the HELP screen.
  865.       Minor changes in the examples in this DOC file.
  866.  
  867. 3.2c  Dec 31, 1991
  868.       Fixed bug in HOLIDAYS.BAT that showed New Year's Eve when
  869.             it should have showed New Year's Day.
  870.             (Thanks to Luther Schliesser for ANOTHER bug report.)
  871.       Modified HOLIDAYS.BAT to show Easter-related holidays 1992-2000
  872.       Modified HOLIDAYS.BAT to give an example of calculating
  873.           anniversaries for a user-specified "special date" (SD)
  874.  
  875. 4.1a  Jan 03, 1992
  876.       Added ability to accept TT, TT, and TTTT
  877.             as pseudodates for current MM, DD, and CCYY.
  878.       Added function: W  (i.e. /Fw)
  879.       Modified this doc file, FDATEX.BAT, and HOLIDAYS.BAT accordingly.
  880.  
  881.       Modified HOLIDAYS.BAT to use new /Fw to show Thanksgiving.
  882.       Added Luther Schliesser's anniversary code to HOLIDAYS.BAT
  883.       Added note on elimination of multiple spaces from /P strings.
  884.       Added note showing how to use #add and negative number to to
  885.             true subtraction.
  886.       Added note: UPDATES AND CURRENT VERSION OF FDATE
  887.